import React from "react";

export const emptyParams = {
  "operator": [],  // 操作人
  "timeStart": "",
  "timeEnd": "",
  "busiId": "", // 业务
  "appId": "", // 应用
  "modelName": "", // 流程名称
  "modelId": "", // 流程标识ID

};


export function getEllipsisCell(cn, v, maxWidth) {
  return (
    <span
      className={cn}
      style={{
        display: "inline-block",
        maxWidth,
      }}
      title={v}
    >
      {v}
    </span>
  );
}

export function getColumns() {
  const columns = [
    {
      title: "日期",
      dataIndex: "operatingTime",
      defaultSortOrder: "descend",
      sorter: true,
    },
    { title: "操作人", dataIndex: "operator" },
    { title: "动作", dataIndex: "action" },
    { title: "流程标识", dataIndex: "modelId" },
    { title: "流程名称", dataIndex: "modelName" },
    {
      title: "流程状态",
      dataIndex: "modelStatus",
      filters: [
        {
          value: "历史",
          text: "历史",
        },
        {
          value: "设计",
          text: "设计",
        },
        {
          value: "运行",
          text: "运行",
        },
      ],
    },
    { title: "版本", dataIndex: "version" },
    { title: "新版本", dataIndex: "newModelId" },
  ];
  return columns;
};
//
// 页码页数改变
export function handlePageChange(pageNum, pageSize) {
  this.setState({ page: { pageNum, pageSize } }, () => {
    this.initData();
  });
};

export function handleTableChange(pagination, filters, sorter) {
  const newParam = {
    operatingTimeOrderBy: sorter.order==="ascend"?"asc":"desc",
    ...filters,
  };
  this.handleParamsChange(newParam);

};

export function getPageProps(current, pageSize, total) {
  return {
    showQuickJumper: true,
    showSizeChanger: true,
    pageSizeOptions: ["10", "20", "30", "40"],
    current,
    pageSize,
    total,
    onChange: this.handlePageChange,
    onShowSizeChange: this.handlePageChange,
  };
}

export function initData() {
  const { dispatch } = this.props;
  dispatch({
    type: "FlowMonitor/getRuleActionList",
    payload: {
      ...this.getQueryParam(),
    },
  });
}
